/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author lab1
 */
@Entity
@Table(name = "users")
@NamedQueries({
    @NamedQuery(name = "User2.findAll", query = "SELECT u FROM User2 u"),
    @NamedQuery(name = "User2.findByUserName", query = "SELECT u FROM User2 u WHERE u.userName = :userName"),
    @NamedQuery(name = "User2.findByPassword", query = "SELECT u FROM User2 u WHERE u.password = :password")})
public class User2 implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "userName")
    private String userName;
    @Column(name = "password")
    private String password;
    @OneToMany(mappedBy = "user2")
    private List<Order2> order2List;

    public User2() {
    }

    public User2(String userName) {
        this.userName = userName;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public List<Order2> getOrder2List() {
        return order2List;
    }

    public void setOrder2List(List<Order2> order2List) {
        this.order2List = order2List;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (userName != null ? userName.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof User2)) {
            return false;
        }
        User2 other = (User2) object;
        if ((this.userName == null && other.userName != null) || (this.userName != null && !this.userName.equals(other.userName))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.User2[userName=" + userName + "]";
    }

}
